<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <script src="./package/vue.js"></script>
  <script>
    Vue.component('parent', {
      data() {
        return {
          msg: ''
        }
      },
      template: `
        <div class="parent">
          <p>我是父组件</p>
          <p>接收到子组件的信息：{{msg}}</p>
          -----------------
          <child v-model="msg"></child>
        </div>
      `,
    })
    Vue.component('child', {
      props: {
        value: String
      },
      data() {
        return {
          msg: this.props.value
        }
      },
      template: `
        <div class="child">
          <p>我是子组件</p>
          <input type="text" v-model="msg" @input="changeData" />
        </div>
      `,
      methods: {
        changeData() {
          this.$emit('input', this.msg)
        }
      }
    })
    var app = new Vue({
      el: '#app',
      template: `<parent></parent>`
    })
  </script>
</body>
</html>